#!/bin/bash

#CIL_VM=mono

seqsampler="$CIL_VM ../seqsampler/bin/Debug/seqsampler.exe"
seqsplit="$CIL_VM ../seqsplit/bin/Debug/seqsplit.exe"
hmmtrain="$CIL_VM ../hmmtrain/bin/Debug/hmmtrain.exe"
hmmeval="$CIL_VM ../hmmeval/bin/Debug/hmmeval.exe"

INPUT=test.xml

# ejecuta una prueba
function test {
 SITE=$1
 PREFIX=$2
 SUFIX=$3

 TRAIN_SAMPLECOUNT_PCT=80
 NSTATES=4

 NAME=s${SITE}p${PREFIX}s${SUFIX}
 SAMPLES=$NAME/samples.xml 
 SAMPLES_TRAIN=$NAME/samples-train.xml
 SAMPLES_VALIDATE=$NAME/samples-validate.xml
 MODEL=$NAME/model.xml

 if [ ! -d $NAME ]; then
  mkdir $NAME
 fi
 
 echo ----INI EXPERIMENTO $NAME Sitio:$SITE $PREFIX:$SUFIX entrena con $TRAIN_SAMPLECOUNT_PCT percent----

 $seqsampler $INPUT --mode=collect -p=$PREFIX -s=$SUFIX --site=$SITE -o=$SAMPLES
 $seqsplit $SAMPLES $SAMPLES_TRAIN $SAMPLES_VALIDATE -p=$TRAIN_SAMPLECOUNT_PCT -r
 $hmmtrain $NSTATES $SAMPLES_TRAIN $MODEL
 
 echo EVALUACION CON MUESTRAS DE ENTRENAMIENTO
 $hmmeval $MODEL $SAMPLES_TRAIN

 echo EVALUACION CON MUESTRAS DE VALIDACION
 $hmmeval $MODEL $SAMPLES_VALIDATE

 echo ----FIN EXPERIMENTO $NAME---- 
}

function a {
 test 0 1 5
 test 0 6 0
 test 0 0 15
 test 0 15 0
 test 0 15 15

 test 1 3 4
 test 1 6 3
 test 1 0 15
 test 1 15 0
 test 1 15 15

 test 2 4 2
 test 2 2 5
 test 2 0 15
 test 2 15 0
 test 2 15 15

 test 3 0 6
 test 3 3 3
 test 3 0 15
 test 3 15 0
 test 3 15 15

 test 4 0 7 
 test 4 0 15
 test 4 15 0
 test 4 15 15

}

function b {
 test 5 3 4
 test 5 4 3
 test 5 2 6
 test 5 0 15
 test 5 15 0
 test 5 15 15

 test 6 7 0 
 test 6 0 15
 test 6 15 0
 test 6 15 15

 test 7 2 4
 test 7 4 2
 test 7 0 15
 test 7 15 0
 test 7 15 15

 test 8 1 6
 test 8 0 8
 test 8 0 10
 test 8 0 15
 test 8 15 0
 test 8 15 15
}

TIMESTART=$(date +%s)

# para usar mejor el CPU
a > o1.txt &
b > o2.txt
wait
cat o1.txt o2.txt > output.txt
rm o1.txt
rm o2.txt

TIMEEND=$(date +%s)
DIFF=$(( $TIMEEND - $TIMESTART ))
echo "EXPERIMENTS TOOK $DIFF SECONDS"